package basic;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;

/**
 * @author： pang-yun
 * @date： 2021-09-01 11:20
 * 功能目的 ：用于  多级目录复制
 */

public class FileCopy {
    public static void main(String[] args) throws IOException {
      Files.walk(Paths.get("G:\\a")).forEach(a->{
          String replace = a.toString().replace("G:\\a", "G:\\b");
          try {
              if (Files.isDirectory(a)){
                  Files.createDirectory(Paths.get(replace));
              }else if (Files.isRegularFile(Paths.get(a.toString()))){
                  Files.copy(a,Paths.get(replace));
                  System.out.println(a);
              }

          } catch (IOException e) {
              e.printStackTrace();
          }
      });

    }
}
